package com.yaaha.controller;

import com.yaaha.pojo.Department;
import com.yaaha.pojo.Employee;
import com.yaaha.service.MyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class MyController {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Autowired
    MyService myService;
    @GetMapping("/getEmployees")
    @ApiOperation("获取所有的雇员")
    public List<Map<String, Object>> getEmployees() {
        String sql = "select * from employee";
        List<Map<String, Object>> userList = jdbcTemplate.queryForList(sql);
        return userList;
    }

    @GetMapping("/getDepartments")
    public List<Department> getDepartments() {
        return myService.getDepartments();
    }


    @GetMapping("/getEmployeess")
    public List<Employee> getEmployeess() {

//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("新开线程");
//            }
//        });

        System.out.println("无内部类");
        return myService.getEmployeess();
    }

}
